package vista;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import bean.JTextFieldValidator;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VistaCategoria extends JFrame{
	private JPanel jPanel1;
	private JButton btnregistrar;
	private JButton btncancelar;
	private JButton btnmodificar;
	private JButton btnbuscar;
	private JButton btnsalir;
	private JTextField txtnombre;
	private JLabel lblcodigo;
	private JLabel lblnombre;
	private JTextField txtcodigo;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VistaCategoria inst = new VistaCategoria();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VistaCategoria() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Categoria");
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1, BorderLayout.CENTER);
				jPanel1.setLayout(null);
				jPanel1.setPreferredSize(new java.awt.Dimension(390, 205));
				{
					txtcodigo = new JTextFieldValidator(JTextFieldValidator.SOLO_NUMEROS);
					jPanel1.add(txtcodigo);
					txtcodigo.setBounds(88, 23, 138, 21);
				}
				{
					lblnombre = new JLabel();
					jPanel1.add(lblnombre);
					lblnombre.setText("Nombre");
					lblnombre.setBounds(28, 64, 49, 14);
				}
				{
					lblcodigo = new JLabel();
					jPanel1.add(lblcodigo);
					lblcodigo.setText("Codigo");
					lblcodigo.setBounds(28, 26, 55, 18);
				}
				{
					txtnombre = new JTextFieldValidator(JTextFieldValidator.SOLO_LETRAS);
					jPanel1.add(txtnombre);
					txtnombre.setBounds(89, 61, 137, 21);
				}
				{
					btnsalir = new JButton();
					jPanel1.add(btnsalir);
					btnsalir.setText("Salir");
					btnsalir.setBounds(207, 193, 105, 22);
					btnsalir.setActionCommand("Salir");
				}
				{
					btnbuscar = new JButton();
					jPanel1.add(btnbuscar);
					btnbuscar.setText("Buscar");
					btnbuscar.setBounds(252, 23, 83, 22);
					btnbuscar.setActionCommand("Buscar");
				}
				{
					btnmodificar = new JButton();
					jPanel1.add(btnmodificar);
					btnmodificar.setText("Modificar");
					btnmodificar.setBounds(207, 139, 105, 22);
					btnmodificar.setActionCommand("Modificar");
				}
				{
					btnregistrar = new JButton();
					jPanel1.add(btnregistrar);
					btnregistrar.setText("Registrar");
					btnregistrar.setBounds(68, 139, 113, 22);
					btnregistrar.setActionCommand("Registrar");
				}
				{
					btncancelar = new JButton();
					jPanel1.add(btncancelar);
					btncancelar.setText("Cancelar");
					btncancelar.setBounds(68, 193, 108, 22);
					btncancelar.setActionCommand("Cancelar");
				}
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	public void addlistener(ActionListener actionlistener){
    	btnbuscar.addActionListener(actionlistener);
    	btnregistrar.addActionListener(actionlistener);
	    btnmodificar.addActionListener(actionlistener);
    	btnsalir.addActionListener(actionlistener);
    	btncancelar.addActionListener(actionlistener);
    }

	
	public void limpiarCancelar(){
		txtcodigo.setEnabled(true);
		txtcodigo.setText("");
		txtnombre.setText("");
		}

	public String getnombre() {
		return txtnombre.getText();
	}

	public String getcodigo() {
		return txtcodigo.getText();
	}	
	
	
	public void setTxtnombre(JTextField txtnombre) {
		this.txtnombre.setText(txtnombre.getText());
	}

	public void setTxtcodigo(JTextField txtcodigo) {
		this.txtcodigo.setText(txtcodigo.getText());
	}

	public void mostrarMensaje(String mensaje) {
		JOptionPane.showMessageDialog(this, mensaje);
	}

	public JTextField getTxtnombre() {
		return txtnombre;
	}

	public JTextField getTxtcodigo() {
		return txtcodigo;
	}
	
	

}
